# Copyright 2024 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
load("//java:repositories.bzl", "JAVA_TOOLS_CONFIG", "REMOTE_JDK_CONFIGS")
load(":check_remotejdk_configs_match.bzl", "validate_configs")

sh_test(
    name = "check_remote_jdk_configs_test",
    srcs = ["check_remote_jdk_configs.sh"],
    args = [
        ",".join([
            config.name,
            config.urls[0],
            config.urls[1] if len(config.urls) > 1 else "",
            config.sha256,
            config.strip_prefix,
        ])
        for configs in REMOTE_JDK_CONFIGS.values()
        for config in configs
    ],
)

sh_test(
    name = "check_remote_java_tools_configs_test",
    srcs = ["check_remote_java_tools_configs.sh"],
    args = [
        ",".join([
            name,
            config["mirror_url"],
            config["github_url"],
            config["sha"],
        ])
        for name, config in JAVA_TOOLS_CONFIG["artifacts"].items()
    ],
)

validate_configs()
